package com.bw.liuyushan.zhuangao4_weektest2.MVP.Fragment;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.bw.liuyushan.mvp_lib.View.BaseFragment;
import com.bw.liuyushan.zhuangao4_weektest2.Adapter.FragmentTableAdapter;
import com.bw.liuyushan.zhuangao4_weektest2.MVP.Contrack.IContrackTest;
import com.bw.liuyushan.zhuangao4_weektest2.MVP.Model.BaseModelTest;
import com.bw.liuyushan.zhuangao4_weektest2.MVP.Presenter.BasePresenterTest;
import com.bw.liuyushan.zhuangao4_weektest2.R;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;

/**
 * ZhuanGao4_WeekTest2
 * file name is : Fragment_Main1
 * created by Ender on 2021/8/23 8:31.
 * author : 刘雨杉
 * Describe(作用):
 */
public class Fragment_Main1 extends BaseFragment<BasePresenterTest> implements IContrackTest.C_ViewTest {
    private TabLayout TabFM1;
    private ViewPager vpFM1;
    ArrayList<Fragment> tablist;
    ArrayList<String> strings;

    @Override
    public int bindLayout() {
        return R.layout.fragment_main1;
    }

    @Override
    public void initView() {
        //防止内存泄露
        ip = new BasePresenterTest(new BaseModelTest(), this);


        TabFM1 = (TabLayout) findViewById(R.id.Tab_FM1);
        vpFM1 = (ViewPager) findViewById(R.id.vp_FM1);
    }

    @Override
    public void initDate() {

        tablist = new ArrayList<>();
        tablist.add(new Fragment_Table1());
        tablist.add(new Fragment_Table2());

        strings = new ArrayList<>();
        strings.add("海淀");
        strings.add("推荐");
        FragmentTableAdapter fragmentTableAdapter = new FragmentTableAdapter(getChildFragmentManager(), tablist, strings);
        vpFM1.setAdapter(fragmentTableAdapter);
        TabFM1.setupWithViewPager(vpFM1);
        vpFM1.setCurrentItem(1);
    }
}
